/*
 * MultisetOPTest.cpp
 *
 * Copyright 2012 Fabian Wenzelmann
 *
 * This file is part of Recognition-Procedures-for-Boolean-Functions.
 *
 * Recognition-Procedures-for-Boolean-Functions is free software: you
 * can redistribute it and/or modify it under the terms of the
 * GNU General Public License as published by the Free Software Foundation,
 * either version 3 of the License, or (at your option) any later version.
 *
 * Recognition-Procedures-for-Boolean-Functions is distributed in the hope
 * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
 * Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Recognition-Procedures-for-Boolean-Functions.
 *
 * If not, see <http://www.gnu.org/licenses/>.
 */

#include <gtest/gtest.h>

#include "bfr/OccurrencePattern.hpp"

namespace bfr { namespace test {

TEST(MultisetOP, insert) {
    OccurrencePattern op(0);

    EXPECT_EQ("{}", op.asString());

    op.addOccurrence(5);
    op.addOccurrence(4);
    op.addOccurrence(3);
    op.addOccurrence(2);

    EXPECT_EQ("{2, 3, 4, 5}", op.asString());
}

TEST(MultisetOP, compare) {
    // test from Smaus' first publication
    // http://www.informatik.uni-freiburg.de/~ki/papers/smaus-tr230.pdf
    OccurrencePattern op1(0);

    for(int i = 0; i < 4; i++)
        op1.addOccurrence(2);

    OccurrencePattern op2(1);
    for(int i = 0; i < 3; i++)
        op2.addOccurrence(2);

    OccurrencePattern op3(2);
    op3.addOccurrence(3);
    op3.addOccurrence(2);
    op3.addOccurrence(2);

    OccurrencePattern op4(3);
    op4.addOccurrence(2);
    op4.addOccurrence(3);

    EXPECT_TRUE(op1 > op2);
    EXPECT_TRUE(op1 > op3);
    EXPECT_TRUE(op1 > op4);

    EXPECT_TRUE(op2 < op1);
    EXPECT_TRUE(op3 < op1);

    EXPECT_TRUE(op2 > op3);
    EXPECT_TRUE(op2 > op4);

    EXPECT_TRUE(op3 > op4);

    EXPECT_FALSE(op1 == op2);
    EXPECT_FALSE(op2 == op3);
    EXPECT_FALSE(op3 == op4);

    EXPECT_TRUE(op1 == op1);
    EXPECT_TRUE(op2 == op2);
    EXPECT_TRUE(op3 == op3);
    EXPECT_TRUE(op4 == op4);

}

}}
